package com.ybl.store.backend.dao.entity.deal;

import com.baomidou.mybatisplus.annotation.TableName;
import com.ybl.store.common.constant.DealStatus;
import com.ybl.store.common.entity.BaseDO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("t_deal_product")
public class DealProductDO extends BaseDO {

    private Long id;

    private Long storeId;

    private Long clerkId;

    private Long customerId;

    private Long productId;

    private Date dealTime;

    private Integer type;

    private Integer totalNumber;

    private Integer currentNumber;

    private BigDecimal totalPayment;

    private BigDecimal currentPayment;

    private Integer dealStatus;

    private String notes;

    public void setDealStatus() {
        setDealStatus(
                Objects.equals(getCurrentNumber(), getTotalNumber()) && Objects.equals(getCurrentPayment(), getTotalPayment())
                        ? DealStatus.end : DealStatus.inProgress
        );
    }
}
